<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <style type="text/css">

        /* tooltip */
        #tooltip{
            position:absolute;
            border:1px solid #ccc;
            background:#333;
            padding:2px;
            display:none;
            color:#fff;
        }
    </style>
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
    <fieldset class="layui-elem-field site-demo-button" style="border:0">
        <form class="layui-form serch" action="{:url('admin/overtime/auditList')}" method="post">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="apply_username" placeholder="申请人姓名模糊搜索" name="apply_username">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="serch">点击查询</button>
                </div>
            </div>
        </form>
    </fieldset>

    <table class="layui-table" lay-size="sm">
        <thead>
        <tr>
            <th>ID</th>
            <th>申请人</th>
            <th>申请人所在部门</th>
            <th>提交人</th>
            <th>申请开始时间</th>
            <th>申请结束时间</th>
            <th>时长（单位：小时）</th>
            <th>工单类型</th>
            <th>说明</th>
            <th>状态</th>
            <th>创建时间</th>
            <th>更新时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="myList" id="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.apply_name}</td>
            <td>{$vo.cate_name}</td>
            <td>{$vo.bag_name}</td>
            <td>{$vo.start_time}</td>
            <td>{$vo.end_time}</td>
            <td>{$vo.duration}</td>
            <td>
                {if condition="$vo.type eq 1"}
                加班
                {elseif condition="$vo.type eq 2" /}
                请假
                {else /}
                -
                {/if}
            </td>
            <td>{$vo.content}</td>
            <td>
                {if condition="$vo.status eq 1"}
                待审批
                {elseif condition="$vo.status eq 2" /}
                已审批
                {elseif condition="$vo.status eq 3" /}
                驳回
                {else /}
                异常
                {/if}
            </td>
            <td>{$vo.create_time}</td>
            <td>{$vo.update_time}</td>
            <td>
                <div class="layui-btn-group">
                    <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-primary radius" radius_id="{$vo.id}" style="margin-right: 0;font-size:12px;">通过</a>
                    <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-primary delete" delete_id="{$vo.id}" style="margin-right: 0;font-size:12px;">驳回</a>
                </div>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div style="padding:0 20px;">{$myList->render()}</div>

    <script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>

    <script type="text/javascript">
        $('.radius').click(function(){
            var id = $(this).attr('radius_id');
            layer.confirm('确定通过？', function(index) {
                $.ajax({
                    url:"{:url('admin/overtime/pass')}",
                    data:{id:id},
                    success:function(res) {
                        if(res == 1) {
                            layer.msg('操作成功！');
                            setTimeout(function(){
                                document.location.reload();
                            },1000)
                        }else{
                            layer.msg('操作失败！');
                            setTimeout(function(){
                                document.location.reload();
                            },1000)
                        }
                    }
                })
            })
        })

        $('.delete').click(function(){
            var id = $(this).attr('delete_id');
            layer.confirm('确定驳回？', function(index) {
                $.ajax({
                    url:"{:url('admin/overtime/fail')}",
                    data:{id:id},
                    success:function(res) {
                        if(res == 1) {
                            layer.msg('操作成功！');
                            setTimeout(function(){
                                document.location.reload();
                            },1000)

                        }else{
                            layer.msg('操作失败！');
                            setTimeout(function(){
                                document.location.reload();
                            },1000)
                        }
                    }
                })
            })
        })
    </script>

    <script>
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            laydate.render({
                elem: '#create_time'
            });
            laydate.render({
                elem: '#end_time'
            });
        });
    </script>
</div>
</body>
</html>
